<template>
  <Header :type="'long'">
    <p class="switchs">
      分销设置&nbsp;
      <el-switch v-model="send" @change="switchTag"> </el-switch>
    </p>
  </Header>
</template>
<script>
import { ISDISTRIBUT, ISDISTRIBUTE } from "../../service";

export default {
  data() {
    return {
      send: false
    };
  },
  created() {
    this.lock();
  },
  methods: {
    showTag(e) {
      this.shows = e;
    },
    async switchTag() {
      await ISDISTRIBUT({ is_distribut: this.send ? 1 : 0 }).then(
        ({ code, msg }) => {
          if (code === 200) this.send = true;
          this.$message({
            message: msg,
            type: code === 200 ? "success" : "error"
          });
        }
      );
    },
    async lock() {
      await ISDISTRIBUTE().then(({ code, data }) => {
        if (code === 200) {
          this.send = data === 1;
        }
      });
    }
  }
};
</script>
<style lang="scss" scoped>
.switchs {
  font-size: 20px;
  font-weight: bold;
  padding-left: 20px;
}
</style>
